package StringDictionary;

import java.util.Observer;

import smarties.SmartNode;

/**
 * Thread lancant la recherche textuelle.
 * 
 * @author buthane
 */
public class SearchThread extends Thread
{
	protected SearchRunnable	searchRunnable;

	public SearchRunnable getSearchRunnable()
	{
		return this.searchRunnable;
	}

	public void stopSearching()
	{
		final Thread thisThread = this;
		Thread thread = new Thread()
		{
			@Override
			public void run()
			{
				synchronized (thisThread)
				{
					thisThread.notify();
				}
			}
		};
		thread.start();
	}

	public void addObserver(Observer o)
	{
		this.searchRunnable.addObserver(o);
	}

	protected SearchThread()
	{

	}

	public SearchThread(SearchRunnable searchRunnable)
	{
		super(searchRunnable);

		this.searchRunnable = searchRunnable;
	}

	public SearchThread(String textToSearch)
	{
		this(new SearchRunnable(textToSearch));
	}

	public SearchThread(String textToSearch,
			SearchResult<SmartNode> searchResult)
	{
		this(new SearchRunnable(textToSearch, searchResult));
	}
}
